package com.linkage.bss.crm.packagemgr.dao.impl;

import java.util.List;
import java.util.Map;

import com.linkage.bss.commons.dao.Page;
import com.linkage.bss.commons.dao.ibatis.BaseDAO;
import com.linkage.bss.crm.packagemgr.dao.IPackageUtilDAO;
import com.linkage.bss.crm.packagemgr.model.PackParamType;
import com.linkage.bss.crm.packagemgr.model.Segment;

/**
 *
 * 包工具
 * @author sgl
 * @date 2013-4-17
 * @version 1.0
 */
public class PackageUtilDAOImpl extends BaseDAO implements IPackageUtilDAO {

	/**
	 * 获取状态列表
	 * @return map key:id,value:状态名
	 */
	public Map<String, String> getAllStatus() {

		return getSqlMapClientTemplate().queryForMap("PackageUtil.getAllStatus", null, "key", "value");
	}

	/**
	 * 以简单方式用给出的序列名seqName直接生成主键值
	 *
	 * @param seqName
	 * @return
	 */
	public Long findSEQNextVal(String seqName) {

		return (Long) getSqlMapClientTemplate().queryForObject("PackageUtil.findSEQNextVal", seqName);

	}

	/**
	 * 根据名称分页查询客户群
	 * @param name
	 * @param page
	 * @return
	 */
	public List<Segment> getSegmentByName(String name, Page page) {

		return queryForPageList("PackageUtil.selectSegmentByName", name, page);
	}

	public List<Map> queryProdSpec(Map map, Page page) {
		return queryForPageList("PackageUtil.queryProdSpec", map, page);
	}

	/**
	 * 非分页查询产品规格
	 * @param map
	 * @return [参数说明]
	 *
	 * @return List<Map> [返回类型说明]
	 * @exception throws [违例类型] [违例说明]
	 * @see [类、类#方法、类#成员]
	 */
	public List<Map> queryProdSpec(Map map) {
		return getSqlMapClientTemplate().queryForList("PackageUtil.queryProdSpecList", map);
	}

	public int queryProdSpecCnt(Map map) {
		return (Integer) getSqlMapClientTemplate().queryForObject("PackageUtil.queryProdSpecCnt", map);
	}

	/**
	 *
	* queryOfferSpec
	* @Description: 根据销售品名称 查询销售品信息
	*  @param map
	*  @return
	 */
	public int queryOfferSpecCnt(Map map) {
		return (Integer) getSqlMapClientTemplate().queryForObject("PackageUtil.queryOfferSpecCnt", map);
	}

	/*
	 *根据销售品名称 查询销售品信息  分页查询
	 */
	public List<Map> queryOfferSpec(Map map, Page page) {
		return queryForPageList("PackageUtil.queryOfferSpec", map, page);
	}

	public List<PackParamType> queryParamType() {
		return getSqlMapClientTemplate().queryForList("PackageUtil.queryParamType");
	}

	/**
	 * 根据包编码查询包的个数
	 *
	 * @return int [返回类型说明]
	 * @exception throws [违例类型] [违例说明]
	 * @see [类、类#方法、类#成员]
	 */
	public int isPackCodeSingle(String packCode) {
		return (Integer) getSqlMapClientTemplate().queryForObject("PackageUtil.isPackCodeSingle", packCode);
	}

	/**
	 * 根据销售品ID获得
	 * 销售品的角色名称
	 * @param offerSpecId
	 * @return [参数说明]
	 *
	 * @return List [返回类型说明]
	 * @exception throws [违例类型] [违例说明]
	 * @see [类、类#方法、类#成员]
	 */
	public List queryOfferRoleNameById(Long offerSpecId) {
		return getSqlMapClientTemplate().queryForList("PackageUtil.queryOfferRoleNameById", offerSpecId);
	}

	public int queryPromoLabel(Map map) {
		return (Integer) getSqlMapClientTemplate().queryForObject("PackageUtil.queryPromoLabelCont", map);
	}

	public List<Map> queryPromoLabel(Map map, Page queryPage) {
		return queryForPageList("PackageUtil.queryPromoLabel", map, queryPage);
	}

}
